

class Car {

    /**
     * 构造器
     * */
    constructor(name, year) {
        this._name = name;
        this._year = year;
    }

    /**
     *  "age" 的类方法，它返回车龄：
     * */
    age() {
        let date = new Date();
        return date.getFullYear() - this.year;
    }

    get name() {
        return this._name;
    }

    set name(value) {
        this._name = value;
    }

    get year() {
        return this._year;
    }

    set year(value) {
        this._year = value;
    }

    toString(  ){
         return this._name + " - " +    this._year ;
    }


}

